#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtGui/QFontDatabase>
#include <QtCore/QDir>
#include "ble_discovery.h"
#include <QObject>

#include <QtCore/QLoggingCategory>
#include <QQmlContext>
#include <QGuiApplication>
#include <QQuickView>

int main(int argc, char *argv[])
{
//    QGuiApplication app(argc, argv);
//    if (qgetenv("QT_QUICK_CONTROLS_1_STYLE").isEmpty()) {
//#ifdef QT_STATIC
//        // Need a full path to find the style when built statically
//        qputenv("QT_QUICK_CONTROLS_1_STYLE", ":/ExtrasImports/QtQuick/Controls/Styles/Flat");
//#else
//        qputenv("QT_QUICK_CONTROLS_1_STYLE", "Flat");
//#endif
//    }
//    QQmlApplicationEngine engine;
//    engine.load(QUrl("qrc:/main.qml"));
//    if (engine.rootObjects().isEmpty())
//        return -1;
//    return app.exec();

    QGuiApplication app(argc, argv);

    ble_discovery device("Simple Peripheral");
    QQuickView *view = new QQuickView;
    view->rootContext()->setContextProperty("device", &device);

    view->setSource(QUrl("qrc:/main.qml"));
    view->setResizeMode(QQuickView::SizeRootObjectToView);
    view->show();
    return app.exec();
}
